	import {
		reactive,
	} from "@vue/composition-api";
	import {
		custom
	} from '@/api/news.js'
export function loadData(){
	
	const tableData = reactive({
		item:[],
		total:0
	})
	
    const tableLoadData = async (data)=>{
		  const requestData = data.tableConfig.requestData
		  const params = {
			  url:requestData.url,
			  method:requestData.method || 'POST',
			  data:requestData.data
		  }
			const res = await custom(params)
			const responseData = res.data.data
			if(responseData&&responseData.length>0){
				tableData.item = responseData
				tableData.total = res.data.total
			}else{
				// 没有数据的时候 
				tableData.item = []
				tableData.total = 0
			}
			
	}
	
	return {
		tableData ,
		tableLoadData
	}
}